package com.lottery.game.common.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.lottery.game.common.BaseObject;
import com.lottery.game.common.json.JsonDateSerialize;

import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.OrderBy;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author : yinlin
 * @version : 1.0
 * @date : 2019-01-28 11:10
 * @Description :
 * @Copyright : Copyright (c) 2018
 * @Company : KeRuYun Technology(Beijing) Chengdu Co. Ltd.
 * @link : com.vartime.easy.spring.boot.tk.mybatis.core.entity.BaseLogicEntity
 */
@Data
@ApiModel
@MappedSuperclass
public class BaseLogicEntity extends BaseObject {
    /**
     * 实体Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "varchar(32) COMMENT '主键ID,自动生成'")
    @ApiModelProperty(value = "主键编号", example = "UUID")
    private String id = UUID.randomUUID().toString().replaceAll("-", "");

    /**
     * 创建时间
     */
    @Column(name = "server_create_time", columnDefinition = "TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '系统创建时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonSerialize(using = JsonDateSerialize.class)
    @ApiModelProperty(value = "系统创建时间", example = "2019-01-28 10:10:10")
    @OrderBy("DESC")
    private Date serverCreateTime;

    /**
     * 更新时间
     */
    @Column(name = "server_update_time", columnDefinition = "TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '系统更新时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @JsonSerialize(using = JsonDateSerialize.class)
    @ApiModelProperty(value = "系统更新时间", example = "2019-01-28 10:10:10")
    private Date serverUpdateTime;

    /**
     * 是否是可用数据
     */
    @Column(name = "usable", columnDefinition = "TINYINT(1) NOT NULL DEFAULT true COMMENT '是否可用'")
    @ApiModelProperty(value = "是否可用", example = "true")
    private Boolean usable = true;
}
